DEFINITION MODULE ResourceMgr;   (* Christoph Fleischer 05.02.85 *)
                                 (* MacIntosh Toolbox Resource Manager Routines *)
                                 (* last modification   06.08.85 fxk*)

FROM MacBase IMPORT LongInt,Handle,StrPtr,OsType;

EXPORT QUALIFIED
  ResSysRef,ResSysHeap,ResPurgeable,ResLocked,ResProtected,ResPreload,ResChanged,
  ResUser,MapReadOnly,MapCompact,MapChanged,ResNotFound,ResFNotFound,AddResFailed,
  AddRefFailed,RmvResFailed,RmvRefFailed,
  ResType,
  InitResources,RsrcZoneInit,CreateResFile,OpenResFile,UseResFile,GetResFileAttrs,
  SetResFileAttrs,UpdateResFile,CloseResFile,SetResPurge,SetResLoad,CountResources,
  GetIndResource,CountTypes,GetIndType,UniqueID,GetResource,GetNamedResource,
  LoadResource,ReleaseResource,DetachResource,ChangedResource,WriteResource,
  HomeResFile,CurResFile,GetResAttrs,SetResAttrs,GetResInfo,SetResInfo,AddResource,
  AddReference,RmveResource,RmveReference,SizeResource,ResError;

CONST
  (*Resource attribute byte*)
  ResSysRef    = 128;            (* Reference to system resource? *)
  ResSysHeap   =  64;            (* System or application heap?   *)
  ResPurgeable =  32;            (* Purgeable resource?           *)
  ResLocked    =  16;            (* Load it in locked?            *)
  ResProtected =   8;            (* Protected?                    *)
  ResPreload   =   4;            (* Load in on OpenResFile?       *)
  ResChanged   =   2;            (* Resource changed?             *)
  ResUser      =   1;            (* User-definable attribute      *)

  MapReadOnly  = 128;            (* Resource file read-only       *)
  MapCompact   =  64;            (* Compact resource file         *)
  MapChanged   =  32;            (* Write map out at update       *)


  ResNotFound  = -192;           (* Resource not found            *)
  ResFNotFound = -193;           (* Resource file not found       *)
  AddResFailed = -194;           (* AddResource failed            *)
  AddRefFailed = -195;           (* AddReference failed           *)
  RmvResFailed = -196;           (* RmveResource failed           *)
  RmvRefFailed = -197;           (* RmveReference failed          *)


TYPE  ResType = OsType; (* ARRAY[0..3] OF CHAR; *)


PROCEDURE InitResources(): INTEGER;                           (*INLINE $A995*)
PROCEDURE RsrcZoneInit;                                       (*INLINE $A996*)
PROCEDURE CreateResFile(fileName: StrPtr);                    (*INLINE $A9B1*)
PROCEDURE OpenResFile  (fileName: StrPtr): INTEGER;           (*INLINE $A997*)
PROCEDURE UseResFile     (refNum:  INTEGER);                  (*INLINE $A998*)
PROCEDURE GetResFileAttrs(refNum:  INTEGER): INTEGER;         (*INLINE $A9F6*)
PROCEDURE SetResFileAttrs(refNum:  INTEGER;  attrs:  INTEGER);(*INLINE $A9F7*)
PROCEDURE UpdateResFile  (refNum:  INTEGER);                  (*INLINE $A999*)
PROCEDURE CloseResFile   (refNum:  INTEGER);                  (*INLINE $A99A*)
PROCEDURE SetResPurge    (install: BOOLEAN);                  (*INLINE $A993*)
PROCEDURE SetResLoad     (AutoLoad:BOOLEAN);                  (*INLINE $A99B*)
PROCEDURE CountResources(theType:  ResType): INTEGER;         (*INLINE $A99C*)
PROCEDURE GetIndResource(theType:  ResType; index:  INTEGER): Handle;
                                                              (*INLINE $A99D*)
PROCEDURE CountTypes():  INTEGER;                             (*INLINE $A99E*)
PROCEDURE GetIndType(VAR theType:  ResType; index:  INTEGER); (*INLINE $A99F*)
PROCEDURE UniqueID  (theType:  ResType):  INTEGER;            (*INLINE $A9C1*)
PROCEDURE GetResource(theType: ResType; ID: INTEGER): Handle; (*INLINE $A9A0*)
PROCEDURE GetNamedResource(theType:  ResType;name: StrPtr): Handle;
                                                              (*INLINE $A9A1*)
PROCEDURE LoadResource(theResource: Handle);                  (*INLINE $A9A2*)
PROCEDURE ReleaseResource(theResource:  Handle);              (*INLINE $A9A3*)
PROCEDURE DetachResource(theResource:  Handle);               (*INLINE $A992*)
PROCEDURE ChangedResource(theResource:  Handle);              (*INLINE $A9AA*)
PROCEDURE WriteResource(theResource:  Handle);                (*INLINE $A9B0*)
PROCEDURE HomeResFile(theResource: Handle): INTEGER;          (*INLINE $A9A4*)
PROCEDURE CurResFile():  INTEGER;                             (*INLINE $A994*)
PROCEDURE GetResAttrs(theResource: Handle): INTEGER;          (*INLINE $A9A6*)
PROCEDURE SetResAttrs(theResource: Handle; attrs: INTEGER);   (*INLINE $A9A7*)
PROCEDURE GetResInfo(theResource:  Handle;
                     VAR theID:    INTEGER;
                     VAR theType:  ResType;
                         name:     StrPtr);                   (*INLINE $A9A8*)
PROCEDURE SetResInfo(theResource:  Handle;
                     theID:        INTEGER;
                         name:     StrPtr);                  (*INLINE $A9A9*)
PROCEDURE AddResource(theResource:  Handle;
                      theType:      ResType;
                      theID:        INTEGER;
                          name:     StrPtr);                  (*INLINE $A9AB*)
PROCEDURE AddReference(theResource:  Handle;
                       theID:        INTEGER;
                          name:     StrPtr);                 (*INLINE $A9AC*)
PROCEDURE RmveResource(theResource:  Handle);                 (*INLINE $A9AD*)
PROCEDURE RmveReference(theResource:  Handle);                (*INLINE $A9AE*)
PROCEDURE SizeResource(theResource: Handle): LongInt;         (*INLINE $A9A5*)
PROCEDURE ResError():  INTEGER;                               (*INLINE $A9AF*)

END ResourceMgr.
